/* 
 * File:   PtrMap.h
 * Author: ucho
 *
 * Created on August 4, 2008, 1:06 AM
 */
#include <map>
#ifndef _PTRMAP_H
#define	_PTRMAP_H
template <typename K, typename V>
class PtrMap {
	typedef typename std::map<K, void*>::iterator tIterador;

public:
	PtrMap():map() {};
	V* get(K key) {
		tIterador it( map.find(key));
		if (it == map.end()) {
			return NULL;
		}
		return (V*) it->second;
	}
	void erase(K key) {
		map.erase(key);
	}
	void put(K key, V* value) {
		V* old = get(key);
		if (old != NULL) {
			delete(old);
		}
		map[key] = (void*)value;
	}
private:
	
	std::map<K, void*> map;
};


#endif	/* _PTRMAP_H */
